package com.wulis.config.swagger;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author WuliBao
 */
@Configuration
public class OpenApiConfig {

    private final OpenApiInfoProperties properties;

    public OpenApiConfig(OpenApiInfoProperties properties) {
        this.properties = properties;
    }

    @Bean
    public OpenAPI openApiInfo() {
        return new OpenAPI().info(new Info().title(properties.getTitle()).description(properties.getDescription())
            .contact(new Contact().name(properties.getContact().getName()).email(properties.getContact().getEmail()))
            .version(properties.getVersion()));
    }
}
